package com.xlw.presenter;

import com.xlw.db.TripDBHelper;
import com.xlw.model.Trip;

import java.util.Date;

/**
 * Created by xinliwei on 2015/7/5.
 *
 * MVP模式中的 P - presenter
 */
public class MainPresenter extends BasePresenter{

    IMainView view;     // 代表视图activity

    public void setView(IMainView view){
        this.view = view;
    }

    public IMainView getView(){
        return this.view;
    }

    @Override
    public void viewFinishLoading() {
        // 在这里调用
    }

    // 测试dao访问
    public void tripDaoTest(){
        Trip trip1 = new Trip();
        trip1.setTopic("夏威夷七日游");
        trip1.setDesc("公司福利,夏威夷七日游,豪华团,包吃包住包飞机包潜水,开心乐翻天!");
        trip1.setStart(new Date());
        trip1.setCategory("出境游");

        Trip trip2 = new Trip();
        trip2.setTopic("韩国济洲岛三日游");
        trip2.setDesc("公司福利,韩国济洲岛三日游,豪华团,包吃包住包飞机包泡菜,开心乐翻天!");
        trip2.setStart(new Date());
        trip2.setCategory("出境游");

        Trip trip3 = new Trip();
        trip3.setTopic("杏石口路半日游");
        trip3.setDesc("个人福利,杏石口路半日游,看看火星时代,尝尝大同削面,开心乐翻天!");
        trip3.setStart(new Date());
        trip3.setCategory("境内游");

//        TripDBHelper tripDBHelper = new TripDBHelper(this);
        TripDBHelper tripDBHelper = new TripDBHelper();
        tripDBHelper.saveTrip(trip1);
        tripDBHelper.saveTrip(trip2);
        tripDBHelper.saveTrip(trip3);

        // 回调,更新视图
        view.showDaoTestResult("ok ok");
    }
}
